package com.api.department.createdepartment;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.api.test.AssertApi;
import com.api.test.UrnType;
import com.zyncro.api.IDepartmentApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(locations = "classpath:/department/department-toedit.xml")
public class CreateDepartment extends AbstractApiTest {

	@Value("#{org_toedit[departmentCreator].appId}")
	private String userUrn;

	@Value("#{org_toedit[departmentCreator].password}")
	private String userPassword;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void test() throws ZyncroApiException {

		String name = "A name";
		String description = null;
		String address = null;
		String telephone = null;
		String email = null;
		String web = null;
		String fax = null;
		boolean showMembers = false;
		String idUserOwner = null;
		String attributes = null;
		boolean followerComment = false;

		ObjectResultApi<String> result = getApi().getService(IDepartmentApiService.class).createDepartment(name, description, address,
				telephone, email, web, fax, showMembers, idUserOwner, attributes, followerComment);

		AssertApi.assertUrnType(result.getObject(), UrnType.GROUP);
	}
}
